package com.robot.base.util;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.Observer;

import com.robot.base.configs.AppConstants;
import com.robot.base.model.FilterBean;

public class LiveDataEventManager {

    public static void postLoginSuccessEvent() {
        LiveDataBus.get().with(AppConstants.LiveKey.LOGIN_SUCCESS).postValue("");
    }

    public static void observerLoginSuccessEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.LOGIN_SUCCESS).observe(owner, observer);
    }

    public static void postPlayCourseEvent(String url) {
        LiveDataBus.get().with(AppConstants.LiveKey.COURSE_PLAY).postValue(url);
    }

    public static void observerPlayCourseEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.COURSE_PLAY).observe(owner, observer);
    }

    public static void postPlayResourceEvent(String url) {
        LiveDataBus.get().with(AppConstants.LiveKey.RESOURCE_PLAY).postValue(url);
    }

    public static void observerPlayResourceEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.RESOURCE_PLAY).observe(owner, observer);
    }

    public static void postResourceFilterEvent(FilterBean filterBean) {
        LiveDataBus.get().with(AppConstants.LiveKey.RESOURCE_FILTER).postValue(filterBean);
    }

    public static void observerResourceFilterEvent(LifecycleOwner owner, @NonNull Observer<FilterBean> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.RESOURCE_FILTER, FilterBean.class).observe(owner, observer);
    }

    public static void postPaySuccessEvent() {
        LiveDataBus.get().with(AppConstants.LiveKey.PAY_SUCCESS).postValue("");
    }

    public static void observerPaySuccessEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.PAY_SUCCESS).observe(owner, observer);
    }

    public static void postCommentSuccessEvent() {
        LiveDataBus.get().with(AppConstants.LiveKey.LOGIN_SUCCESS).postValue("");
    }

    public static void observerCommentSuccessEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.LOGIN_SUCCESS).observe(owner, observer);
    }

}
